package com.wanmait.movie.util;

import com.github.pagehelper.PageInfo;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class PageUtils<T> {

    public PageInfo<T> getPageInfo(Page page, List<T> objList){
        PageInfo<T> pageInfo = new PageInfo<>();
        pageInfo.setTotal(page.getTotalElements());
        pageInfo.setPages(page.getTotalPages());
        pageInfo.setPageNum(page.getPageable().getPageNumber());
        pageInfo.setPageSize(page.getPageable().getPageSize());
        pageInfo.setList(page.getContent());
        pageInfo.calcByNavigatePages(7);
        return pageInfo;
    }

}
